package com.rules.admin.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.rules.admin.entity.DataDictDetailModel;
import com.rules.admin.service.DataDictDetailService;
import com.rules.admin.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

@RequestMapping({"/data_dict_detail"})
@Controller
public class DataDictDetailController {
   @Autowired
   private DataDictDetailService dataDictDetailService;

   @RequestMapping(
      method = {RequestMethod.GET}
   )
   @ResponseBody
   public IPage<DataDictDetailModel> queryPage(Long dataId, String dataName, IPage<DataDictDetailModel> page) {
      return this.dataDictDetailService.queryPage(dataId, dataName, page);
   }

   @RequestMapping(
      value = {"/{id}"},
      method = {RequestMethod.GET}
   )
   @ResponseBody
   public DataDictDetailModel getRule(@PathVariable("id") Long id) {
      return this.dataDictDetailService.getById(id);
   }

   @RequestMapping(
      method = {RequestMethod.POST}
   )
   @ResponseBody
   public Map<String, Object> addDataDict(@RequestBody DataDictDetailModel dataDictDetailModel) {
      this.dataDictDetailService.save(dataDictDetailModel);
      return ResultUtils.getSuccessResultData();
   }

   @RequestMapping(
      value = {"/{id}"},
      method = {RequestMethod.PUT}
   )
   @ResponseBody
   public Map<String, Object> updateRule(@RequestBody DataDictDetailModel dataDictDetailModel) {
      this.dataDictDetailService.updateById(dataDictDetailModel);
      return ResultUtils.getSuccessResultData();
   }

   @RequestMapping(
      value = {"/{id}"},
      method = {RequestMethod.DELETE}
   )
   @ResponseBody
   public Map<String, Object> deleteDataDict(@PathVariable("id") Long id) {
      this.dataDictDetailService.removeById(id);
      return ResultUtils.getSuccessResultData();
   }

   public static void main(String[] args) {
      Map<Integer, Integer> a = new HashMap();
      Map<Integer, Integer> b = new LinkedHashMap();

      for(int i = 0; i < 1000000; ++i) {
         a.put(i, i);
         b.put(i, i);
      }

      Long start = System.currentTimeMillis();

      Integer var5;
      for(Iterator var4 = a.keySet().iterator(); var4.hasNext(); var5 = (Integer)var4.next()) {
      }

      Long end1 = System.currentTimeMillis();

      Integer var6;
      for(Iterator var9 = b.keySet().iterator(); var9.hasNext(); var6 = (Integer)var9.next()) {
      }

      Long end2 = System.currentTimeMillis();
      System.out.println(end1 - start);
      System.out.println(end2 - end1);
   }
}
